<?php

use Illuminate\Support\Facades\Route;

/**
 * Api for unauthorized users.
 */
Route::post('sms/code', 'SmsController@code')->name('sms.code');

Route::post('users', 'UsersController@store')->name('users.store');

Route::post('captchas', 'CaptchasController@store')->name('captchas.store');
Route::post('auth', 'AuthController@store')->name('auth.store');
Route::get('auth/wechat', 'AuthController@wechat')->name('auth.wechat');
Route::post('auth/wxmini/phone', 'AuthController@wxminiPhone')->name('auth.wxmini.phone');
Route::post('auth/wxmini', 'AuthController@wxmini')->name('auth.wxmini');
Route::get('auth/wechat/key', 'AuthController@wechatSessionKey')->name('auth.wechatSessionKey');

Route::post('auth/alipay', 'AuthController@alipay')->name('auth.alipay');
Route::put('auth/token', 'AuthController@update')->name('auth.update');
Route::post('auth/logout', 'AuthController@logout')->name('auth.logout');
Route::delete('auth', 'AuthController@destroy')->name('auth.destroy');
Route::put('passwords/reset', 'PasswordsController@reset')->name('reset.password.reset');

Route::get('broadcasts', 'BroadcastsController@index')->name('broadcasts.index');

//Route::get('slides/{position}', 'SlidesController@index')->name('slides.index');

Route::get('categories', 'CategoriesController@index')->name('categories.index');

Route::get('products/list', 'ProductsController@index')->name('products.index');
Route::post('products/search', 'ProductsController@search')->name('products.search');
Route::get('products/{id}', 'ProductsController@show')->name('products.show');
Route::post('product/skus/show', 'ProductSkusController@show')->name('product.skus.show');

Route::get('hot/products', 'HotProductsController@index')->name('hot.products.index');

Route::get('comments/products', 'CommentsController@index')->name('comments.products.index');

Route::post('withdraws/freelances/notify', 'WithdrawsFreelancesController@notify')->name('withdraws.freelances.notify');
Route::post('withdraws/freelances/gd_notify', 'WithdrawsFreelancesController@gd_notify')->name('withdraws.freelances.gd_notify');

Route::get('redis/{id}', 'RedisController@show')->name('redis.show');
Route::get('gold/rounds', 'GoldRoundsController@index')->name('gold.rounds.index');

Route::get('gold/products', 'GoldProductsController@index')->name('gold.products.index');

Route::get('ranks', 'RanksController@index')->name('ranks.index');
Route::get('ranks/config', 'RanksController@config')->name('ranks.config');

Route::get('circles', 'CirclesController@index')->name('circles.index');
Route::get('seckill/products', 'SeckillProductsController@index')->name('seckill.products.index');
Route::get('seckill/products/info', 'SeckillProductsController@info')->name('seckill.products.info');
Route::get('seckill/products/{id}', 'SeckillProductsController@show')->name('seckill.products.show');

Route::get('groups', 'GroupsController@index')->name('groups.index');
Route::get('group/products', 'GroupsController@products')->name('groups.products');
Route::get('groups/info/{id}', 'GroupsController@show')->name('groups.show');

/**
 * Api for authorized users.仟商集 
 */
Route::get('slides/{position}', 'SlidesController@index')->name('slides.index');
Route::get('activities', 'ActivitiesController@index')->name('activities.index');
Route::get('activity/{id}', 'ActivitiesController@show')->name('activity.show');
Route::get('points/products', 'PointsProductsController@index')->name('points.products.index');
Route::get('floors', 'MerchantsController@floors')->name('merchants.floors');
Route::get('merchants', 'MerchantsController@index')->name('merchants.index');
Route::get('home/merchants', 'MerchantsController@homeNewMechants')->name('merchants.new');
Route::get('merchant/categories', 'MerchantsController@categories')->name('merchants.categories');
Route::get('merchants/{id}', 'MerchantsController@show')->name('merchants.show');
Route::post('merchant/auth', 'AuthController@merchantAuth')->name('merchant.store');
Route::get('coupon/all/records', 'CouponController@allRecords')->name('coupon.all.records');
Route::get('home/activities', 'ActivitiesController@homeActivities')->name('activities.home');
Route::get('prize/records', 'ActivitiesController@prizeRecord')->name('activities.prizeRecord'); //积分兑换优惠卷
Route::middleware('auth:merchant')->group(function () { 
	Route::get('coupon/merchant/records', 'CouponController@couponMerchantRecords')->name('coupon.merchant.records');
	Route::post('coupon/use', 'CouponController@use')->name('coupon.use');
});	

/**
 * Api for authorized users.
 */
Route::middleware('auth:api')->group(function () { 
	//积分商城
	Route::post('points/products', 'PointsProductsController@store')->name('points.products.store'); //积分兑换优惠卷
	Route::post('take/coupons', 'CouponController@takeCoupon')->name('coupon.take.coupon'); //积分兑换优惠卷
	Route::get('coupon/records', 'CouponController@records')->name('coupon.records');
	Route::get('coupon/record', 'CouponController@record')->name('coupon.record');
	Route::get('coupon/park/record', 'CouponController@parkRecord')->name('coupon.parkRecord');
	Route::post('share', 'UsersController@share')->name('users.share');
	//抽奖
	Route::post('prize', 'ActivitiesController@prizeTake')->name('activities.prizeTake'); //积分兑换优惠卷

	Route::post('suggestion', 'UsersController@takeSuggestion')->name('users.takeSuggestion'); //建议

	Route::get('balance/records', 'BalanceController@records')->name('balance.records');

	Route::post('signin', 'UsersController@Signin')->name('users.signin'); //建议

	//group
	Route::get('groups/my', 'GroupsController@myList')->name('groups.my.list');
	Route::get('groups/cards', 'GroupsController@cards')->name('groups.cards');
	Route::post('groups/open', 'GroupsController@open')->name('groups.open');
	Route::post('groups/join', 'GroupsController@join')->name('groups.join');

	Route::get('my/products', 'ProductsController@myCommandProducts')->name('my.products');
	Route::post('auth/alipay/payload', 'AuthController@alipayPayload')->name('auth.alipay.payload');
	Route::put('passwords/set/pay/code', 'PasswordsController@setPayCode')->name('passwords.set.pay.code');

	Route::post('files', 'FilesController@store')->name('files.store');

	Route::post('auth/wxmini/reset/openid', 'AuthController@resetWxminiOpenid')->name('auth.wxmini.reset.openid');
	Route::post('auth/wechat/bind', 'AuthController@wechatBind')->name('auth.wechat.bind');
	Route::post('auth/alipay/bind', 'AuthController@alipayBind')->name('auth.alipay.bind');

	Route::get('users/show', 'UsersController@show')->name('users.show');
	Route::get('users/pay/method', 'UsersController@payMethod')->name('users.pay.method');
	Route::get('users/child/info', 'UsersController@userChildInfo')->name('users.child.info');
	Route::post('users/call', 'UsersController@call')->name('users.call');
	Route::get('users/from/invite/code', 'UsersController@fromInviteCode')->name('users.from.invite.code');
	Route::put('users', 'UsersController@update')->name('users.put');
	Route::post('users/bind/pay/method', 'UsersController@bindUserPayMethod')->name('users.bind.pay.method');
	Route::put('users/set/child/{user}/nickname', 'UsersController@setChildNickname')->name('users.set.child.nickname');
	Route::post('users/storm/support', 'UsersController@support')->name('users.storm.support');

	Route::post('users/auth', 'UsersController@authUser')->name('users.auth');
	Route::get('users/team', 'UsersController@team')->name('users.team');
	Route::get('users/team/search', 'UsersController@search')->name('users.team.search');
	Route::get('users/agents', 'UsersController@agents')->name('users.agents');


	Route::get('users/free/withdraws', 'UsersController@free')->name('users.free');

	Route::get('users/bonus/rank/today', 'UsersController@todayBonusRank')->name('users.today.bonus.rank');
	Route::get('users/bonus/rank/all', 'UsersController@allBonusRank')->name('users.all.bonus.rank');

	Route::get('invites/string/{product?}', 'InvitesController@inviteString')->name('invites.string');
	Route::get('invites/poster/user', 'InvitesController@userPoster')->name('invites.poster.user');
	Route::get('invites/poster/{product}', 'InvitesController@productPoster')->name('invites.poster.product');
	Route::get('invites/poster/circle/{circle}', 'InvitesController@circlePoster')->name('invites.poster.circle');

	Route::resource('addresses', 'AddressesController');
	Route::put('addresses/update/{address}', 'AddressesController@update')->name('addresses.update.address');
	Route::get('addresses/default/address', 'AddressesController@def')->name('addresses.default.address');

	Route::get('notifications', 'NotificationsController@index')->name('notifications.index');
	Route::get('notifications/types', 'NotificationsController@types')->name('notifications.types');
	Route::get('notifications/count', 'NotificationsController@count')->name('notifications.count');
	Route::put('notifications/{id}/read', 'NotificationsController@read')->name('notifications.put.read');
	Route::put('notifications/read/type', 'NotificationsController@readType')->name('notifications.put.read.type');
	Route::put('notifications/read/all', 'NotificationsController@readAll')->name('notifications.put.read.all');
	Route::put('notifications/{id}/read', 'NotificationsController@read')->name('notifications.read');
	Route::put('notifications/read/type', 'NotificationsController@readType')->name('notifications.read.type');
	Route::put('notifications/read/all', 'NotificationsController@readAll')->name('notifications.read.all');

	Route::get('searches/history', 'SearchesController@history')->name('searches.history');
	Route::delete('searches', 'SearchesController@destroy')->name('searches.destroy');

	Route::get('gold/charges', 'GoldChargesController@index')->name('gold.charges.index');
	Route::post('gold/charges', 'GoldChargesController@store')->name('gold.charges.store');

	Route::get('gold/beans', 'GoldBeansController@index')->name('gold.beans.index');
	Route::post('gold/beans/transfer', 'GoldBeansController@transfer')->name('gold.beans.transfer');
	Route::get('gold/beans/config', 'GoldBeansController@config')->name('gold.beans.config');

	Route::get('gold/coins', 'GoldCoinsController@index')->name('gold.coins.index');
	Route::get('gold/cashes', 'GoldCashesController@index')->name('gold.cashes.index');
	Route::get('gold/subsidies', 'GoldSubsidiesController@index')->name('gold.subsidies.index');

    Route::post('gold/cashes/buy', 'GoldCashesController@buy')->name('gold.cashes.buy');
    Route::post('gold/cashes/transfer', 'GoldCashesController@transfer')->name('gold.cashes.transfer');



    Route::get('gold/wastes', 'GoldWastesController@index')->name('gold.wastes.index');
    Route::post('gold/wastes/subsidy', 'GoldWastesController@subsidy')->name('gold.wastes.subsidy');
    Route::post('gold/wastes/order', 'GoldWastesController@order')->name('gold.wastes.order');

	Route::get('gold/records', 'GoldRecordsController@index')->name('gold.records.index');
	Route::get('gold/records/examine/count', 'GoldRecordsController@examineCount')->name('gold.records.examine.count');
	Route::get('gold/records/voucher/list', 'GoldRecordsController@voucherList')->name('gold.records.voucher.list');
	Route::get('gold/records/count', 'GoldRecordsController@count')->name('gold.records.count');
	Route::get('gold/records/counts', 'GoldRecordsController@counts')->name('gold.records.counts');
	Route::post('gold/records/budget', 'GoldRecordsController@budget')->name('gold.records.budget');
	Route::post('gold/records/enter', 'GoldRecordsController@enter')->name('gold.records.enter');
	Route::post('gold/records/check', 'GoldRecordsController@check')->name('gold.records.check'); 
	Route::post('gold/records', 'GoldRecordsController@store')->name('gold.records.store');
	Route::post('gold/records/voucher', 'GoldRecordsController@voucher')->name('gold.records.voucher');
	Route::post('gold/records/{record}/resell', 'GoldRecordsController@resell')->name('gold.records.resell')->where('record', '[0-9]+');
	Route::post('gold/records/batch/pay', 'GoldRecordsController@batchPay')->name('gold.records.batch.pay');
	Route::post('gold/records/batch/pay/alipay', 'GoldRecordsController@batchPayByAlipay')->name('gold.records.batch.pay.alipay');
	Route::post('gold/records/batch/pay/wxpay', 'GoldRecordsController@batchPayByWxpay')->name('gold.records.batch.pay.wxpay');
	Route::post('gold/records/batch/examine', 'GoldRecordsController@batchExamine')->name('gold.records.batch.examine');
	Route::post('gold/records/batch/resell', 'GoldRecordsController@batchResell')->name('gold.records.batch.resell');
	Route::post('gold/records/split', 'GoldRecordsController@split')->name('gold.records.split');
	Route::post('gold/records/take', 'GoldRecordsController@take')->name('gold.records.take');
	Route::post('gold/records/contact', 'GoldRecordsController@contact')->name('gold.records.contact');
	Route::get('gold/records/pay/config', 'GoldRecordsController@config')->name('gold.records.config');
	Route::get('gold/news', 'GoldNewsController@index')->name('gold.news.index');

	Route::get('orders', 'OrdersController@index')->name('orders.index');
	Route::get('orders/count', 'OrdersController@count')->name('orders.count');
	Route::get('orders/counts', 'OrdersController@counts')->name('orders.counts');
	Route::delete('orders/{order}', 'OrdersController@destroy')->name('orders.destroy');
	Route::post('orders', 'OrdersController@store')->name('orders.store');
	Route::get('orders/{order}', 'OrdersController@show')->name('orders.show');
	Route::post('orders/{order}/receive', 'OrdersController@receive')->name('orders.receive');
	Route::post('orders/{order}/close', 'OrdersController@close')->name('orders.close');
	Route::post('orders/{order}/cancel', 'OrdersController@cancel')->name('orders.cancel');
	Route::get('orders/{order}/express', 'OrdersController@express')->name('orders.express');

	Route::get('order/refunds/reasons', 'OrderRefundsController@reasons')->name('order.refunds.reasons');
	Route::post('order/refunds', 'OrderRefundsController@store')->name('order.refunds.store');
	Route::get('order/refunds/{item}/show', 'OrderRefundsController@show')->name('order.refunds.show');
	Route::get('order/refunds/{orderRefund}/negos', 'OrderRefundsController@negos')->name('order.refunds.negos');

	Route::post('comments/product', 'CommentsController@product')->name('comments.product');

	Route::get('withdraws/free/fee', 'WithdrawsController@free')->name('withdraws.free.fee');

	Route::get('withdraws', 'WithdrawsController@index')->name('withdraws.index');
	Route::post('withdraws', 'WithdrawsController@withdrawStore')->name('withdraws.store');
	Route::get('withdraws/auth', 'WithdrawsController@auth')->name('withdraws.auth');


	Route::post('withdraws/xzbpay/auth', 'WithdrawsXzbPayController@auth')->name('withdraws.xzbpay.auth');
	Route::post('withdraws/xzbpay', 'WithdrawsXzbPayController@store')->name('withdraws.xzbpay.store');
	Route::get('withdraws/xzbpay/record', 'WithdrawsXzbPayController@record')->name('withdraws.xzbpay.record');

	Route::post('withdraws/mybank', 'WithdrawsMyBankController@store')->name('withdraws.mybank.store');


	Route::post('withdraws/sandpay', 'WithdrawsSandPayController@store')->name('withdraws.sandpay.store');
	Route::get('withdraws/sandpay/record', 'WithdrawsSandPayController@record')->name('withdraws.sandpay.record');
	Route::get('withdraws/config', 'WithdrawsController@config')->name('withdraws.config');

	Route::get('banks', 'BanksController@index')->name('banks.index');
	Route::get('bank/info', 'BanksController@info')->name('banks.info');

	Route::post('bank/cards', 'BankCardsController@store')->name('bank.cards.store');
	Route::get('bank/cards', 'BankCardsController@index')->name('bank.cards.index');
	Route::put('bank/cards/{card}/update', 'BankCardsController@update')->name('bank.cards.update');
	Route::delete('bank/cards/{card}/destroy', 'BankCardsController@destroy')->name('bank.cards.destroy');


	Route::get('vip/purchases', 'VipPurchasesController@index')->name('vip.purchases.index');
	Route::post('vip/purchases/buy', 'VipPurchasesController@store')->name('vip.purchases.store');
	Route::post('vip/purchases/use', 'VipPurchasesController@use')->name('vip.purchases.use');
	Route::post('vip/purchases/gift', 'VipPurchasesController@gift')->name('vip.purchases.gift');


	Route::get('apples', 'ApplesController@index')->name('apples.index');
	Route::get('apples/records', 'ApplesController@records')->name('apples.records');
	Route::post('apples/transfer', 'ApplesController@transfer')->name('apples.transfer');
	Route::post('apples/exchange', 'ApplesController@exchange')->name('apples.exchange');

	Route::get('apples/config', 'ApplesController@config')->name('apples.config');

	Route::get('apple/trees', 'AppleTreesController@index')->name('apple.trees.index');
	Route::post('apple/trees/buy', 'AppleTreesController@store')->name('apple.trees.store');
	Route::get('apple/trees/records', 'AppleTreesController@records')->name('apple.trees.records');
	

	Route::get('reward/records', 'RewardsController@records')->name('rewards.records');
	Route::get('reward/one/day/records', 'RewardsController@oneDayRecords')->name('rewards.one.day.records');


	Route::post('links', 'LinksController@store')->name('links.store');
	Route::get('tests', 'TestsController@index')->name('tests.index');


	Route::post('seckill/products', 'SeckillProductsController@store')->name('seckill.products.store');


	
	/**
	 * Inner pay.
	 */
	Route::post('pays/storms/{record}/gold/coin', 'PaysController@payStormByGoldCoin')->name('pays.storms.gold.coin');
	Route::post('pays/orders/{order}/gold/coin', 'PaysController@payOrderByGoldCoin')->name('pays.orders.gold.coin');
	Route::post('pays/orders/{order}/gold/bean', 'PaysController@payOrderByGoldBean')->name('pays.orders.gold.bean');

	Route::post('pays/orders/{order}/balance', 'PaysController@payOrderByBalance')->name('pays.orders.balance');

	/**
	 * Outer pay.
	 */


	Route::post('pays/vip/purchases/{purchase}/alipay', 'PaysController@payVipPurchaseByAlipay')->name('pays.vip.purchases.alipay');
	Route::post('pays/vip/purchases/{purchase}/wxpay', 'PaysController@payVipPurchaseByWxpay')->name('pays.vip.purchases.wxpay');
	Route::post('pays/vip/purchases/{purchase}/balance', 'PaysController@payVipPurchaseByBalance')->name('pays.vip.purchases.balance');
	Route::post('pays/orders/{order}/alipay', 'PaysController@payOrderByAlipay')->name('pays.orders.alipay');
	Route::post('pays/orders/{order}/aliwap', 'PaysController@payOrderByAliwap')->name('pays.orders.aliwap');
	Route::post('pays/orders/{order}/wxpay', 'PaysController@payOrderByWxpay')->name('pays.orders.wxpay');
	Route::post('pays/orders/{order}/wxmini', 'PaysController@payOrderByWxmini')->name('pays.orders.wxmini');
	Route::post('pays/orders/{order}/apple', 'PaysController@payOrderByApple')->name('pays.orders.apple');
	Route::post('pays/orders/{order}/wxwap', 'PaysController@payOrderByWxwap')->name('pays.orders.wxwap');
	Route::post('pays/orders/{order}/ada/wxmini', 'PaysController@payOrderByAdaWxmini')->name('pays.orders.ada.wxmini');
	Route::post('pays/gold/charges/{charge}/alipay', 'PaysController@payGoldChargeByAlipay')->name('pays.gold.charge.alipay');
	Route::post('pays/gold/charges/{charge}/wxpay', 'PaysController@payGoldChargeByWxpay')->name('pays.gold.charge.wxpay');
	Route::post('pays/gold/charges/{charge}/aliwap', 'PaysController@payGoldChargeByAliwap')->name('pays.gold.charge.aliwap');
	Route::post('pays/gold/charges/{charge}/ada/wxmini', 'PaysController@payGoldChargeByAdaWxmini')->name('pays.gold.charge.ada.wxmini');
	Route::post('pays/gold/charges/{charge}/sandwap', 'PaysController@payGoldChargeBySandwap')->name('pays.gold.charge.sandwap');
	Route::post('pays/gold/charges/{charge}/sandwx', 'PaysController@payGoldChargeBySandwx')->name('pays.gold.charge.sandwx');

	Route::post('pays/gold/charges/{charge}/gold/coin', 'PaysController@payGoldChargeByGoldCoin')->name('pays.gold.charge.gold.coin');
});
